package com.ithema.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import net.minidev.json.annotate.JsonIgnore;
import sun.misc.Regexp;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.time.LocalDateTime;

@Data
public class User {
    @NotNull
    private Integer id;//主键ID
    @Pattern(regexp = "^\\S{5,16}$", message = "用户名格式不正确")
    private String username;//用户名
    @Pattern(regexp = "^\\S{5,16}$", message = "密码需要5-16位")
    @JsonIgnore
    private String password;//密码
    @NotEmpty
    @Pattern(regexp = "^\\S{1,10}", message = "昵称需要1-10位")
    private String nickname;//昵称
    @Email(message = "请输入正确格式的邮箱")
    @NotEmpty
    private String email;//邮箱
    private String userPic;//用户头像地址
    //时间格式转换注解
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;//创建时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;//更新时间

}
